<template>
  <div class="dialog" @click="close">
    <div class="content-dialog" @click="onClick">
      <div class="header">文件信息</div>
      <div class="main">
        <img :src="fileData.url" alt="" />
        <p>文件名称:{{ fileData.name }}</p>
        <p>存储路径:/2021-11-22/{{ fileData.name }}</p>
        <p>文件类型:{{ fileData.type }}</p>
        <p>文件大小:{{ fileData.size | size }}</p>
        <p>访问链接:{{ fileData.url }}</p>
      </div>
      <div class="footer">
        <button @click="close">关闭</button>
        <button @click="del">删除</button>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: ["fileData"],
  data() {
    return {};
  },
  filters: {
    size(value) {
      return (value / 1024).toFixed(2) + "kb";
    },
  },
  methods: {
    close() {
      this.$emit("close");
    },
    onClick(e){
      e.stopPropagation()
    },
    del(){
      this.$emit('del',this.fileData.id)
    }
  },
  components: {},
};
</script>
<style lang="scss" scoped>
.dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: end;
  z-index: 999;
  .content-dialog {
    width: 50%;
    height: 100%;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    .header {
      height: 60px;
      border-bottom: 1px solid #ccc;
      line-height: 60px;
      padding: 0 20px;
    }
    .main {
      flex: 1;
      img {
        width: 100%;
        height: 300px;
      }
      p {
        margin: 10px;
      }
    }
    .footer {
      height: 60px;
      border-top: 1px solid #ccc;
      display: flex;
      align-items: center;
      justify-content: end;
      button {
        width: 60px;
        height: 40px;
        margin: 0 10px;
        border: 1px solid #ccc;
        outline: none;
      }
    }
  }
}
</style>